<?php

use think\migration\Migrator;
use think\migration\db\Column;
use Phinx\Db\Adapter\MysqlAdapter;

class SystemInfo extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function up()
    {
        $this->table('system_info')
            ->addColumn('key', 'string', ['limit' => 50, 'comment' => '配置名'])
            ->addColumn('value', 'string', ['limit' => 100, 'comment' => '配置值'])
            ->addColumn('vtype', 'string', ['limit' => 50, 'comment' => '参数类型'])
            ->addColumn('create_at', 'datetime', ['default' => 'CURRENT_TIMESTAMP'])
            ->addColumn('update_at', 'datetime', ['update' => 'CURRENT_TIMESTAMP'])
            ->addIndex(['key'])
            ->save();

        systeminfo('version.lastest', 1);
        systeminfo('version.min', 1);
        systeminfo('version.lastest_text', 'v1.0');
        systeminfo('version.min_text', 'v1.0');
    }

    public function down()
    {
        $this->table('system_info')->drop();
    }
}
